<template>
  <!-- 分包设置对话框 -->
  <el-dialog title="分包设置" :visible.sync="visable" width="500px" append-to-body>
    <el-form ref="from" :model="form" label-width="120px">
      <el-form-item label="自动分包" prop="isSplit">
        <el-checkbox v-model="form.isSplit" />
      </el-form-item>
      <el-form-item label="需要连trackId" prop="trackId">
        <el-checkbox :disabled="!form.isSplit" v-model="form.trackId" />
      </el-form-item>
      <el-form-item label="每包数量" prop="percent">
        <el-input :disabled="!form.isSplit" v-model="form.packageCount" placeholder="请输入每一子包的数量" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submit">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { taskInitialize } from '@/api/mark/qaTaskV1'
export default {
  name: 'TaskInitDialog',

  data() {
    return {
      visable: false,
      form: {
        taskId: null,
        isSplit: true,
        trackId: true,
        packageCount: 100,
      },
    }
  },

  methods: {
    submit() {
      taskInitialize(this.form).then((res) => {
        this.visable = false
        if (res.code == 200) {
          this.msgSuccess('开始分包，请在大约10分钟后进入任务列表查看。')
        } else {
          this.msgError(res.msg)
        }
      })
    },

    cancel() {
      this.visable = false
    },

    open(task) {
      this.form = { taskId: task.taskId }
      this.resetForm('form')
      this.visable = true
    },
  },
}
</script>

<style></style>
